<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta name="viewport"
	content="initial-scale=1, maximum-scale=1, user-scalable=no">
<meta name="format-detection" content="telephone=no">
<title>售票页面</title>
<link rel="stylesheet" href="${ctx}/static/plug/weui/css/weui.css"
	media="all">

<link rel="stylesheet" href="${ctx}/static/plug/weui/css/weuix.css"
	media="all">
	
	<link rel="stylesheet" href="${ctx}/static/css/sellticket/ticketPurchase.css"
	media="all">
<style type="text/css">
</style>



</head>
<body>
	<div class="header"></div>
	<div class="header headers">
		<p>综合售票页面</p>
		<div class="datetime">
			<span class="times" id="times"></span> <span>${user.entNo}，你好</span>
		</div>
		<div class="tips">
			 <span>当前设备连接失败</span>
		</div>
	</div>
	<div class="ticketType">
		<c:forEach var="ticketInfo" items="${ticketInfoList}">
		
			<div class="ticket_purchases">
					<input class="ticketInfoId" id="${ticketInfo.id}"
							value="${ticketInfo.price}" type="hidden">
							<input class="ticketInfoNum"
							value="${ticketInfo.minimumNumber}" type="hidden">
							<input class="childRate"
							value="${ticketInfo.childRate}" type="hidden">
					${ticketInfo.name }
			</div>
		</c:forEach>
	</div>
	<div class="bodyer">
		<div class="subjects">
		<h2 align="center" style="color: #f39800">票价：<span id="ticketInfoPrice"></span>元/张，儿童票打<span  id="ticketChildRate"></span>折</h2>
			<div class="ticket">
				<div class="qrcode" style="border: 0; padding: 0;"><img class="qrcodeImg"  id="qrcodeImg0"></div>
				<div class="ticket_01">
					<div class="weui-cell">
						<div class="weui-cell__hd">
							<label class="weui-label">姓名</label>
						</div>
						<div class="weui-cell__bd">
							<input class="weui-input userName" id="userName0" placeholder="请输入姓名（必填）" value=" " maxlength="15"  type="text">
						</div>
					</div>
					<div class="weui-cell">
						<div class="weui-cell__hd">
							<label class="weui-label">身份证</label>
						</div>
						<div class="weui-cell__bd">
							<input class="weui-input idNumber " id="idNumber0" placeholder="请输入身份证（选填）" value=" "  oninput="if(value.length>18)value=value.slice(0,18)" type="number">
							<input type="hidden" class="bid"  value="">
						</div>
					</div>
				</div>
				<div class="ticket_02">
					<p>
						成人票 <span> 1张</span>
					</p>
					<p>
						儿童票 <span class="ui-tic-title"
							style="margin-right: 8%; font-size: 14x; padding-top: 2px; float: right;">
							<span class="reduce" id="reduce0">-</span> <span
							class="ticketNum ticketNums" style="width: 46px;">0</span> <span
							class="plus" id="plus0">+</span>
							张</span>
					</p>
				</div>
				<div class="ticket_03 delTicket">
					<p>移除</p>
				</div>
			</div>
	
			
		</div>
	</div>
	<br>
	<br>
	<p class="addTicket"><span>添加游客</span></p>
	
	<div style="width: 100%; height: 100px;"></div>

	<br>
	<br><br>
	<br><br>
	<br>
	<div class="tailer">
		<div class="prices">
			<p>
				共 <span class="ticketCalculation" id="ticketCalculation">0</span>
				张， 成人票 <span class="adultNum" id="adultNum">0</span> 张， 儿童票 <span
					class="childrenNum" id="childrenNum">0</span> 张， 合计： <span id="totalPrice">0</span>
				元
			</p>
		</div>
		<div>
			<div class="returns">
				<p id="returnKey">返回主菜单</p>
			</div>
			<div class="returns">
				<p id="printing">打印纸质票</p>
			</div>
			<div class="returns">
				<p id="activation">激活绑定纸质票</p>
			</div>
			
			<div class="returns">
				<p id="refund">退票</p>
			</div>
			
			<div class="returns">
				<p id="collection">取票</p>
			</div>
		</div>
	</div>
	
	<div class="floatingWindow" id="floatingWindowActivation">
		<div>
			<p>共需要激活<span class="totalticket" id="totalticket"></span>张二维码纸质票</p>
			<p>已激活：<span class="Adultticket" id="Adultticket">0</span>/<span class="totalAdultticket" id="totalAdultticket">0</span>张</p>
			<br>
			<p class="floatingSpan"><span class="Continue">继续售票</span><span class="returnKeys">返回主菜单</span></p>
		</div>
	</div>
	
	<div class="floatingWindow" id="floatingWindowPrinting">
		<div>
			<br>
			<p>正在打印中。。。。</p>
			<p><span id="printNum">0</span>/<span  id="printNumTatol"></span></p>
			<br>
			<br>
			<p class="floatingSpan"><span class="Continue">继续售票</span><span class="returnKeys">返回主菜单</span></p>
		</div>
	</div>
</body>

<script src="${ctx}/static/js/jquery/jquery.min.js"></script>

<script src="${ctx}/static/plug/weui/js/zepto.weui.js"
	type="text/javascript"></script>
	<script src="base64js.min.js"></script>


<script>
var idVals = 0;
var deviceSubmission = false;
	$(function() {
		var ticketInfoId = 0;
		var ticketInfo = {
				"minimumNumber" :"",
				"price" :"",
				"ticketInfoId":"",
				"childRate" :"",
		}
		$(".ticket_purchases").click(function() {
			console.log($(this))
			$(".ticket_purchases").css("background-color" , "white");
			$(".ticket_purchases").css("color" , "#888");
			$(this).css("background-color" , "#286abf");
			$(this).css("color" , "white");
			var ticketInfoNum =$(this).find(".ticketInfoNum").val();
			console.log(ticketInfoNum)
			var childRate =$(this).find(".childRate").val();
			console.log(childRate)
			var ticketPrices = $(this).find(".ticketInfoId").val();
			var num = $(this).find(".ticketInfoId").attr("id");
			ticketPrices = parseInt(ticketPrices);
			num = parseInt(num);
			childRate = parseFloat(childRate);
			ticketInfoNum = parseInt(ticketInfoNum);
			ticketInfo.minimumNumber = ticketInfoNum;
			ticketInfo.price = ticketPrices;
			ticketInfo.ticketInfoId = num;
			ticketInfo.childRate = childRate;
			
			if(ticketPrices){
				prices = ticketPrices;
				console.log(prices);
			}
			if((ticketInfo.minimumNumber - $(".ticket").length) > 0){
				for (var i = 0; i < (ticketInfo.minimumNumber - $(".ticket").length) ; i++) {
					$(".subjects").append( htmlVals());
					ticketCalculation();
		       		$(".delTicket>p").click(function() {
						if($(".ticket").length >ticketInfo.minimumNumber){
							$(this).parent().parent().remove();
							ticketCalculation();
						}
					});
		       		plusAndReduce();
				}
			}else if ((ticketInfo.minimumNumber - $(".ticket").length) < 0) {
				for (var i = 0; i < ($(".ticket").length - ticketInfo.minimumNumber); i++) {
					$(".delTicket>p").last().click();
				}
			}
			console.log(ticketInfo)
			
			$("#ticketInfoPrice").text((ticketInfo.price/100).toFixed(2));
			$("#ticketChildRate").text(ticketInfo.childRate*10)
			num = parseInt(num);
			ticketInfoId = num;
		});
		
		
		$(".ticket_purchases").first().click();
		
		plusAndReduce();
		function plusAndReduce() {
			console.log(idVals)
			$("#plus" + idVals).click(function() {
				var num = $(this).prev().text();
				num = parseInt(num);
				num += 1;
				$(this).prev().text(num);
				ticketCalculation();
			});
			$("#reduce" + idVals).click(function() {
				var num = $(this).next().text();

				num = parseInt(num);
				if (num > 0) {
					num = (num - 1);
					$(this).next().text(num);
				}
				ticketCalculation();
			});
			$("#idNumber"+idVals).bind("input propertychange",function() {
    			var idNumber = $(this).val()
    			$(this).css("border-bottom","1px solid #777");
    			if(reg.test(idNumber)){
    				$(this).css("border","0px solid #999");
    				for (var i = 0; i < $(".subjects").find(".idNumber").length; i++) {
		    			console.log($(".subjects").find(".idNumber").eq(i).val())
		    			for (var j = 0; j <  $(".subjects").find(".idNumber").length; j++) {
		    				console.log($(".subjects").find(".idNumber").eq(j).val())
		    				if(i != j && $(".subjects").find(".idNumber").eq(i).val().length != 0){
		    					if($(".subjects").find(".idNumber").eq(i).val() == $(".subjects").find(".idNumber").eq(j).val()){
		    					 $.toast("重复证件号！", "forbidden");
		           				 $(this).val("");
		           				 $(this).css("border-bottom","1px solid #777");
		           				 return;
		           					}
		    					}
							}
		    			}
    				}
    			});
    		$("#userName"+idVals).bind("input propertychange",function() {
    			var userName = $(this).val()
    			$(this).css("border-bottom","1px solid #777");
    			if(2 <= userName.length && userName.length<= 5){
    				$(this).css("border","0px solid #999");
    			}
    			
    		});
		}
		
		$("#collection").click(function() {
			window.location.href="${ctx}/takeOrRetreat/toCheckCodePick?modeType=" + 1;
		});
		$("#refund").click(function() {
			window.location.href="${ctx}/takeOrRetreat/toCheckCodePick?modeType="  + 2;
		});
		
		
		var socket; 
		
		webSocketConnect();
		function webSocketConnect() {
			if(localStorage.serverIP != null && localStorage.serverPort != null){
				var serverIP = localStorage.serverIP;
		   		var serverPort = localStorage.serverPort;
		   		var host = "ws://" + serverIP + ":" + serverPort + "/"
		        socket = new WebSocket(host);
		   	 	try {
	           	  socket.onopen = function (msg) {
		               localStorage.serverIP = serverIP;
		               localStorage.serverPort = serverPort;
		               $(".tips").css("display","none")
		               deviceSubmission = true;
	            	};
	              socket.onmessage = function (msg) {
	                if (typeof msg.data == "string") {
	                	var data = $.parseJSON(msg.data);
	                	console.log(data)
	                	if(data.code == "000"){
							var data = data.data;
							console.log(data)
							if(data.print_result == "000000"){
								var params = {
										"orderDetailId":data.ticket_id
									}
								$.post("${ctx}/takeOrRetreat/printTicket",params  , function(obj) {
									if(obj.result){
										var printNum = $("#printNum").text();
										printNum = parseInt(printNum)
										$("#printNum").text(printNum + 1);
										$.toast(data.print_status);
										if($("#printNum").text() == $("#printNumTatol").text()){
											window.location.reload();
										}
									}else {
										$.toast(obj.msg, "forbidden");
									}
						        });
							}else if(data.print_result == "111111"){
								$.toast(data.print_status, "forbidden");
							}
                		}
	                	
	                	if(data.code == "002"){
	                		localStorage.deviceNo = data.device_id;
							var resultStr = data.data;
							console.log(resultStr);
							var name = resultStr.name;
							var idNumber = resultStr.cid;
							var bid = resultStr.bid;
							var pic = resultStr.pic;
							name   =   name.replace(/\s+/g,"");  
							console.log(bid)
							for (var i = 0; i < $(".subjects").find(".idNumber").length; i++) {
								if($(".subjects").find(".idNumber").eq(i).val() == idNumber){
									 $.toast("重复证件号！", "forbidden");
									return;
									}
								}
							for (var i = 0; i < $(".subjects").find(".idNumber").length; i++) {
								if($(".subjects").find(".idNumber").eq(i).val().length == 0){
									$(".username").eq(i).val(name);
									$(".idNumber").eq(i).val(idNumber);
									$(".bid").eq(i).val(bid);
									$(".qrcodeImg").eq(i).attr("src","data:image/jpg;base64,"+pic);
									$(".username").eq(i).css("border","0px solid #999");
									$(".idNumber").eq(i).css("border","0px solid #999");
									return;
									}
								}
							
							$(".subjects").append(htmlVals());
							plusAndReduce();
							ticketCalculation();
							$(".delTicket>p").click(function() {
			    				if($(".ticket").length >ticketInfo.minimumNumber){
			    					$(this).parent().parent().remove();
			    					ticketCalculation();
			    					}
			    				});
							$(".username").last().val(name);
							$(".idNumber").last().val(idNumber);
							$(".bid").last().val(bid);
							$(".qrcodeImg").last().attr("src","data:image/jpg;base64,"+pic);
							$(".username").last().css("border","0px solid #999");
							$(".idNumber").last().css("border","0px solid #999");
							
	            			}
	                	
	                		if(activationSwitch){
	                			if(data.code == "001"){
	                				var resultStr =  data.data.qrcode;
	                				if( resultStr){
	                					uuid = resultStr;
	                					var params = {
	                							"uuid" : uuid ,
	                						}
	                					$.post("${ctx}/takeOrRetreat/getCheckCode",params  , function(obj) {
	                						console.log(obj)
		                					if(activationIndex < userIdInfoList.length){
		                						var ticketInfoId = ticketInfo.ticketInfoId;
		                						var params = {
		                								"userIdInfo" : JSON.stringify(userIdInfoList[activationIndex]),
		                								"checkCode" : obj.shortQrcode.checkCode ,
		                								"ticketInfoId" : ticketInfoId ,
		                								"orderId" : orderId
		                							}
		                						$.post("${ctx}/selling/binding",params  , function(obj) {
		                							console.log(obj)
		                							if(obj.result){
		                								$("#totalAdultticket").text()
		                    							activationIndex++;
		                    							$("#Adultticket").text(activationIndex);
		                								}else {
		                								 $.toast("无效二维码", "forbidden");
														}
		                			        		});
		                						}
	                						});
	                					}else {
	                					 $.toast("二维码不对！", "forbidden");
										}
	                				}
	                			}
		                	}else {
		                    $.toast("非文本消息！", "forbidden");
		                	}
	            		};
	              socket.onclose = function (msg) { 
	            	  $.confirm("连接设备失败是否继续连接", "提示", function() {
	             		 webSocketConnect();
	                  }, function() {
	                      //取消操作
	                      $(".tips").css("display","block")
	                      deviceSubmission = false;
	                  });
	              }
	        	}catch (ex) {
		            log(ex);
		            webSocketConnect();
	        	}
			}else {
				$(".tips").css("display","block")
				deviceSubmission = false;
			}
		};
		
		
		
		var userIdInfoList ;
		var activationIndex = 0;
		var orderId;
		var activationSwitch = false;
		var submission = true;
		$("#activation").click(function() {
			if(!deviceSubmission){
				$.toast("设备未连接成功无法使用", "forbidden");
				return;
			}
			if(submission == false){
				return;
			}
			userIdInfoList = new Array();
			for (var i = 0; i < $(".ticket_01").length; i++) {
				var userIdInfoId = new Object();
					if($(".ticket_01").eq(i).find(".userName").val().length !=0 && $(".ticket_01").eq(i).find(".idNumber").val().length !=0){
						userIdInfoId.userName = $(".ticket_01").eq(i).find(".userName").val();
						console.log(userIdInfoId.userName)
						console.log(2 >userIdInfoId.userName.length ||5 <userIdInfoId.userName.length)
						if(2 >userIdInfoId.userName.length ||5 <userIdInfoId.userName.length){
							 $.toast("游客姓名不正确", "forbidden");
							 return;
						}
						userIdInfoId.idNumber = $(".ticket_01").eq(i).find(".idNumber").val();
						if(userIdInfoId.idNumber != "" && !reg.test(userIdInfoId.idNumber)){
							 $.toast("游客身份证输入不正确", "forbidden");
							return;
						}
						userIdInfoId.bid = $(".ticket_01").eq(i).find(".bid").val();
						userIdInfoId.childNums = $(".ticket").eq(i).find(".ticketNums").text();
						userIdInfoList[i] = userIdInfoId;
					}
				}
			if(userIdInfoList.length == 0){
				 $.toast("没有输入游客信息", "forbidden");
					return;
			}
			var ticketInfoId = ticketInfo.ticketInfoId;
			var params = {
					"userIdInfoList" : JSON.stringify(userIdInfoList),
					"ticketInfoId" : ticketInfoId ,
			}
			submission = false;
			$.post("${ctx}/selling/activation",params  , function(obj) {
				$("#floatingWindowActivation").css("display","block");
				submission = true;
				console.log(obj);
				if(obj.result){
					$("#totalAdultticket").text()
					activationIndex = 0;
					orderId =  obj.ticketOrder.id;
					var userIdInfoListNew = new Array();
					for (var i = 0; i < userIdInfoList.length; i++) {
						console.log(userIdInfoList[i].childNums);
						var userIdInfo = userIdInfoList[i];
						if(userIdInfo.childNums>=0){
							var num = userIdInfo.childNums;
							for (var j = 0; j <= num; j++) {
								var newUserIdInfo = new Object();
								newUserIdInfo.childNums = j;
								newUserIdInfo.userName = userIdInfo.userName
								newUserIdInfo.idNumber = userIdInfo.idNumber
								userIdInfoListNew.push(newUserIdInfo);
							}
						}
					}
					console.log(userIdInfoListNew);
					userIdInfoList = new Array();
					userIdInfoList = userIdInfoListNew;
					activationSwitch = true;
					$("#totalAdultticket").text(userIdInfoList.length)
				}
				
        	});
			
			
		});
		$("#printing").click(function() {
			if(!deviceSubmission){
				$.toast("设备未连接成功无法使用", "forbidden");
				return;
			}
			
			if(submission == false){
				return;
			}
			userIdInfoList = new Array();
			for (var i = 0; i < $(".ticket_01").length; i++) {
				var userIdInfoId = new Object();
				if($(".ticket_01").eq(i).find(".userName").val().length !=0 && $(".ticket_01").eq(i).find(".idNumber").val().length !=0){
					userIdInfoId.userName = $(".ticket_01").eq(i).find(".userName").val();
					console.log(userIdInfoId.userName)
					console.log(2 >userIdInfoId.userName.length ||5 <userIdInfoId.userName.length)
					if(2 >userIdInfoId.userName.length ||5 <userIdInfoId.userName.length){
						 $.toast("第"+(i+1)+"名游客姓名不正确", "forbidden");
						 return;
					}
					userIdInfoId.idNumber = $(".ticket_01").eq(i).find(".idNumber").val();
					if(userIdInfoId.idNumber != "" && !reg.test(userIdInfoId.idNumber)){
						 $.toast("第"+(i+1)+"名游客身份证输入不正确", "forbidden");
						return;
					}
					userIdInfoId.bid = $(".ticket_01").eq(i).find(".bid").val();
					console.log($(".ticket_01").eq(i).find(".bid").val())
					userIdInfoId.childNums = $(".ticket").eq(i).find(".ticketNums").text();
					console.log(userIdInfoId.bid)
					userIdInfoList[i] = userIdInfoId;
				}
			}
			if(userIdInfoList.length == 0){
				 $.toast("没有输入游客信息", "forbidden");
					return;
			}
			var ticketInfoId = ticketInfo.ticketInfoId;
			var params = {
					"userIdInfoList" : JSON.stringify(userIdInfoList),
					"ticketInfoId" : ticketInfoId ,
			}
			submission = false;
			$.post("${ctx}/selling/placeAnOrder",params  , function(obj) {
				$("#floatingWindowPrinting").css("display","block");
				
				submission = true;
				if(obj.result){
					var ticketOrderDetailVoList= obj.ticketOrderDetailVoList;
					$("#printNumTatol").text(ticketOrderDetailVoList.length);
					for (var i = 0; i < ticketOrderDetailVoList.length; i++) {
						var ticketOrderDetailVo = ticketOrderDetailVoList[i];
						delete ticketOrderDetailVo["insertMap"];
						delete ticketOrderDetailVo["qrCode"];
						delete ticketOrderDetailVo["printTime"];
						delete ticketOrderDetailVo["createTime"];
						delete ticketOrderDetailVo["entryTime"];
						delete ticketOrderDetailVo["lastVerifyTime"];
						delete ticketOrderDetailVo["updateTime"];
						delete ticketOrderDetailVo["validTime"];
						console.log(ticketOrderDetailVo);
						var cmd = {
								"cmd":"print",
								"qrcode_val":ticketOrderDetailVo.checkCode,
								"qrcode_img":ticketOrderDetailVo.qrCodeStr,
								"ticket_id":ticketOrderDetailVo.id,
								"ticket_Val" : ticketOrderDetailVo
						};
						console.log(cmd);
						socket.send(JSON.stringify(cmd));
					}
				}
				
        	});
			
			
			//打印 
		});
		
		
		function aesHexDecrypt(src) {
			var key = CryptoJS.enc.Utf8.parse("fb18fc197e644d38");
			console.log(src)
			console.log(CryptoJS.enc.Utf8.parse(src))
			var encryptedBase64Str = CryptoJS.enc.Base64.stringify(CryptoJS.enc.Hex.parse(src));
			console.log(encryptedBase64Str)
		    var decryptedData = CryptoJS.AES.decrypt(encryptedBase64Str, key, {
		    	mode: CryptoJS.mode.ECB,
			    padding: CryptoJS.pad.Pkcs7
		    });
			console.log(decryptedData)
		    var decryptedStr = decryptedData.toString(CryptoJS.enc.Utf8);
			console.log(decryptedStr)
			return decryptedStr;
		}
		
		
		
		var reg=/^[1-9][0-9]{5}(19|20)[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|30|31)|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|[1-2][0-9]))[0-9]{3}([0-9]|x|X)$/;

		ticketCalculation();
		function ticketCalculation() {
			var num = 0;
			var adultNum = 0;
			var childrenNum = 0;
			for (var i = 0; i < $(".ticket").length; i++) {
				var idNumber = $(".ticket").eq(i).find(".idNumber").val()
					adultNum ++;
					childrenNum += parseInt($(".ticketNums").eq(i).text());
			}
			console.log(adultNum)
			$("#ticketCalculation").text(num);
			$("#price").text(num*ticketInfo.price/100);
			num = adultNum + childrenNum;
			$("#ticketCalculation").text(num);
			$("#adultNum").text(adultNum);
			$("#childrenNum").text(childrenNum);
			$("#totalPrice").text((adultNum*ticketInfo.price/100 + childrenNum*ticketInfo.childRate*ticketInfo.price/100).toFixed(2));
		}
		
       
       	$(".addTicket > span").click(function() {
       		
       		$(".subjects").append( htmlVals());
			ticketCalculation();
       		$(".delTicket>p").click(function() {
				if($(".ticket").length >ticketInfo.minimumNumber){
					$(this).parent().parent().remove();
					ticketCalculation();
				}
			});
       		plusAndReduce();
		});
       	
       	
		
		getNowFormatDate();
		
		function htmlVals() {
			idVals++;
			var htmlVal = '<div class="ticket"><div class="qrcode" style="border: 0; padding: 0;"><img class="qrcodeImg" id="qrcodeImg'+idVals+'" ></div><div class="ticket_01"><div class="weui-cell"><div class="weui-cell__hd"><label class="weui-label">姓名</label></div>'+
			'<div class="weui-cell__bd"><input class="weui-input userName" id="userName'+idVals+'" placeholder="请输入姓名（必填）" maxlength="15"   type="text"></div></div><div class="weui-cell">'+
			'<div class="weui-cell__hd"><label class="weui-label">身份证</label></div><div class="weui-cell__bd"><input class="weui-input idNumber" id="idNumber'+idVals+'" placeholder="请输入身份证（必填）" '+
			'oninput="if(value.length>18)value=value.slice(0,18)"  type="number"><input type="hidden" class="bid"  value=""></div></div></div><div class="ticket_02"><p>成人票 <span> 1张</span></p><p>儿童票 <span class="ui-tic-title"'+
			'style="margin-right: 8%; font-size: 14x; padding-top: 2px; float: right;"><span class="reduce" id="reduce'+idVals+'">-</span> <span class="ticketNum ticketNums" style="width: 46px;">0</span> <span '+
			'class="plus" id="plus'+idVals+'">+</span>张</span></p></div><div class="ticket_03 delTicket"><p>移除</p></div></div>'
			return htmlVal;
		}

		$("#returnKey").click(function() {
			window.location.href="${ctx}/selling/index";
		});
		$(".Continue").click(function() {
			if($("#Adultticket").text() == $("#totalAdultticket").text()){
				window.location.reload();
			}
		});
		$(".returnKeys").click(function() {
			if($("#Adultticket").text() == $("#totalAdultticket").text()){
				window.location.href="${ctx}/selling/index";
			}
		});

	});
	

	function getNowFormatDate() {
		var date = new Date();
		var seperator1 = "-";
		var seperator2 = ":";
		var month = date.getMonth() + 1;
		var strDate = date.getDate();
		var secondStr = date.getSeconds();
		var minuteStr = date.getMinutes();
		if (month >= 1 && month <= 9) {
			month = "0" + month;
		}
		if (strDate >= 0 && strDate <= 9) {
			strDate = "0" + strDate;
		}
		if (secondStr >= 0 && secondStr <= 9) {
			secondStr = "0" + secondStr;
		}
		if (minuteStr >= 0 && minuteStr <= 9) {
			minuteStr = "0" + minuteStr;
		}
		var currentdate = date.getFullYear() + seperator1 + month + seperator1
				+ strDate + " " + date.getHours() + seperator2 + minuteStr
				+ seperator2 + secondStr;
		$("#times").text(currentdate);
		setTimeout(getNowFormatDate, 1000);
	}
</script>


</html>